options compress=YES;
libname manasi ''; 
libname f831 '';

* MERGE PARENTAL EARNINGS, PARENTAL SSI, PARENTAL DI, AND SIBLING SSI INTO MAIN DATA SET;

data manasi.kids_ssr_full_nwithsummfypar;

	merge 
		manasi.kids_ssr_full_nwithsummfy 
			(drop=n_termreas: 
			n_cdrunfavyr_: n_N01unfavyr_: n_N04unfavyr_: n_N20unfavyr_:
			n_N40unfavyr_: n_N43unfavyr_: n_N44unfavyr_: n_S06unfavyr_:
			n_M02unfavyr_: n_payavg_:
			in=from_nwithsummfyx)

		manasi.par_831_hunmerge_wide
			(keep=hun par1_ssn par2_ssn par1_sex_ssr par2_sex_ssr 
				par1_dobyy_ssr par2_dobyy_ssr  
				n_par831di_: n_par831ssi_: 
				n_par831di0206_: n_par831ssi0206_: 
				in=from_par831x)

		manasi.par_mbr_hunmerge_wide 
			(keep=hun 	n_hhmbayr_: n_hhmbayr0206_: 
						n_hhdiindyr_: n_hhdiindyr0206_: 
			in=from_mbrx)

		manasi.par_ssr_hunmerge_wide 
			(keep=hun 	n_hhcombpay_: n_hhonssi_: 
						n_hhcombpay0206_: n_hhonssi0206_: 
			in=from_hhssrx)

		manasi.ssr_kids_wsibstats
			(keep=hun numsib_ever n_sibpayall_: n_sibnumon_: in=from_sibx)

		manasi.kids_comb_wsibapps_wide
			(keep=hun n_sibappnum_: in=from_sibappx)

		f831.kid831summ_allyrs
			(keep=ssn n_kid: rename=(ssn=hun) in=from_kid831x)

		manasi.par_numi_hunmerge_wide
			(keep=hun pardeathtot pardeathtot0206 pardod1-pardod7 in=fromparnumix)

		manasi.numident
			(rename=(ssn=hun dod=kiddod) keep=ssn dod in=kiddeathx)
		;

	by hun;
	if from_nwithsummfyx=1;
	from_nwithsummfy=from_nwithsummfyx;
	from_par831=from_par831x;
	from_mbr=from_mbrx;
	from_hhssr=from_hhssrx;
	from_sib=from_sibx;
	from_sibapp=from_sibappx;
	from_kid831=from_kid831x;
	from_parnumi=fromparnumix;
	from_kidnumi=kiddeathx;
run;


proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_par831;
	table from_nwithsummfy, from_par831;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_mbr;
	table from_nwithsummfy, from_mbr;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_hhssr;
	table from_nwithsummfy, from_hhssr;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_sib;
	table from_nwithsummfy, from_sib;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_sibapp;
	table from_nwithsummfy, from_sibapp;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_kid831;
	table from_nwithsummfy, from_kid831;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_parnumi;
	table from_nwithsummfy, from_parnumi;
run;

proc tabulate data=manasi.kids_ssr_full_nwithsummfypar;
	class from_nwithsummfy from_kidnumi;
	table from_nwithsummfy, from_kidnumi;
run;
